package org.jrpc.common.codec;

/**
 * Created by Administrator on 2017/6/28.
 */

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.jrpc.common.baen.RpcResponse;
import org.msgpack.MessagePack;

import java.io.IOException;

/**
 * 编码工具
 */
public class MsgPackEncode extends MessageToByteEncoder<RpcResponse>{
    @Override
    protected void encode(ChannelHandlerContext ctx, RpcResponse msg, ByteBuf out) throws IOException {
        out.writeBytes(new MessagePack().write(msg));
    }
}